// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.TransformManagement
{
	public sealed partial class Settings
	{
		[JsonInclude]
		[JsonPropertyName("align_checkpoints")]
		public bool? AlignCheckpoints { get; set; }

		[JsonInclude]
		[JsonPropertyName("dates_as_epoch_millis")]
		public bool? DatesAsEpochMillis { get; set; }

		[JsonInclude]
		[JsonPropertyName("deduce_mappings")]
		public bool? DeduceMappings { get; set; }

		[JsonInclude]
		[JsonPropertyName("docs_per_second")]
		public float? DocsPerSecond { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_page_search_size")]
		public int? MaxPageSearchSize { get; set; }
	}

	public sealed partial class SettingsDescriptor : SerializableDescriptorBase<SettingsDescriptor>
	{
		internal SettingsDescriptor(Action<SettingsDescriptor> configure) => configure.Invoke(this);
		public SettingsDescriptor() : base()
		{
		}

		private bool? AlignCheckpointsValue { get; set; }

		private bool? DatesAsEpochMillisValue { get; set; }

		private bool? DeduceMappingsValue { get; set; }

		private float? DocsPerSecondValue { get; set; }

		private int? MaxPageSearchSizeValue { get; set; }

		public SettingsDescriptor AlignCheckpoints(bool? alignCheckpoints = true)
		{
			AlignCheckpointsValue = alignCheckpoints;
			return Self;
		}

		public SettingsDescriptor DatesAsEpochMillis(bool? datesAsEpochMillis = true)
		{
			DatesAsEpochMillisValue = datesAsEpochMillis;
			return Self;
		}

		public SettingsDescriptor DeduceMappings(bool? deduceMappings = true)
		{
			DeduceMappingsValue = deduceMappings;
			return Self;
		}

		public SettingsDescriptor DocsPerSecond(float? docsPerSecond)
		{
			DocsPerSecondValue = docsPerSecond;
			return Self;
		}

		public SettingsDescriptor MaxPageSearchSize(int? maxPageSearchSize)
		{
			MaxPageSearchSizeValue = maxPageSearchSize;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (AlignCheckpointsValue.HasValue)
			{
				writer.WritePropertyName("align_checkpoints");
				writer.WriteBooleanValue(AlignCheckpointsValue.Value);
			}

			if (DatesAsEpochMillisValue.HasValue)
			{
				writer.WritePropertyName("dates_as_epoch_millis");
				writer.WriteBooleanValue(DatesAsEpochMillisValue.Value);
			}

			if (DeduceMappingsValue.HasValue)
			{
				writer.WritePropertyName("deduce_mappings");
				writer.WriteBooleanValue(DeduceMappingsValue.Value);
			}

			if (DocsPerSecondValue.HasValue)
			{
				writer.WritePropertyName("docs_per_second");
				writer.WriteNumberValue(DocsPerSecondValue.Value);
			}

			if (MaxPageSearchSizeValue.HasValue)
			{
				writer.WritePropertyName("max_page_search_size");
				writer.WriteNumberValue(MaxPageSearchSizeValue.Value);
			}

			writer.WriteEndObject();
		}
	}
}